////////////////////////////////////////////////////////////////////////////////
// Filename: texture2d.cpp
////////////////////////////////////////////////////////////////////////////////
#include "texture2d.hpp"

Texture2D::Texture2D() {
	m_texture = NULL;
}

Texture2D::~Texture2D() {

}

bool Texture2D::Initialize(ID3D11Device* device, WCHAR* filename) {
	HRESULT result;

	result = D3DX11CreateShaderResourceViewFromFileW(device, filename, NULL, NULL, &m_texture, NULL);
	if (FAILED(result)) {
		return false;
	}

	D3DX11_IMAGE_INFO info;
	D3DX11GetImageInfoFromFileW(filename, NULL, &info, NULL);

	m_width = info.Width;
	m_height = info.Height;

	return true;
}

void Texture2D::Shutdown() {
	if (m_texture) {
		m_texture->Release();
		m_texture = NULL;
	}
}

ID3D11ShaderResourceView* Texture2D::GetTexture() {
	return m_texture;
}

unsigned int Texture2D::GetWidth() {
	return m_width;
}

unsigned int Texture2D::GetHeight() {
	return m_height;
}
